public      get_second_mul
    

ss5      segment     code
rseg    ss5

tmp             equ     48h

;---------------------------------------------------------------------------
;input: a(keeps)
;output: R2R3.R4s
get_second_mul:
    mov     a,@r1
    inc     r1
    subb    a,#30h
    swap    a
    mov     tmp,a

    mov     a,@r1
    subb    a,#30h
    add     a,tmp

   
    call    bcd_to_hex

   
   
    mov     b,#06h
    mul     ab
    
    
    mov     r6,b
    mov     r7,a
    call    hex2_to_bcd
    mov     a,r4
    add     a,#30h
    mov     r2,a        ;write back to r2

   

    mov     a,r5
    anl     a,#0f0h
    swap    a
    add     a,#30h
    mov     r3,a        ;write back to r3
    
    mov     a,r5
    anl     a,#0fh
    add     a,#30h
    mov     r4,a        ;write back to r4
    

    ret


;-------------------------   
;input:a
;output:a    
bcd_to_hex:
    mov     b,#10H 
	div     ab
    mov     r4,b
	mov     b,#10 
	mul     ab
	add     a,r4
	ret
;------------------------- 

;-----------------------------------------
;input: R6,R7
;output: R3,R4,R5,change register group 
 
hex2_to_bcd:
    clr     a
	mov     r3,a
	mov     r4,a
	mov     r5,a
	mov     r2,#10h 
loop0_hex2_to_bcd:
    mov     a,r7 
	rlc     a
	mov     r7,a
	mov     a,r6
	rlc     a
	mov     r6,a
	mov     a,r5 
	addc    a,r5
	da      a 
	mov     r5,a
	mov     a,r4
	addc    a,r4
	da      a
	mov     r4,a
	mov     a,r3
	addc    a,r3
	mov     r3,a 
	djnz    r2,loop0_hex2_to_bcd
    
exit_loop0_hex2_to_bcd:
    ret
 
;---------------------------------------------
end